package com.zz.admin.testDataTypesManagement.controller;

import com.zz.admin.testDataTypesManagement.dto.TestDataTypesDto;
import com.zz.admin.testDataTypesManagement.service.TestDataTypesService;
import java.util.List;
import java.util.Map;

import com.zz.common.base.dto.PageListResultDto;
import com.zz.common.base.dto.ResponseDTO;
import com.zz.common.base.dto.ResultDto;
import com.zz.common.constants.ApiConstants;

import io.swagger.annotations.Api;
import jakarta.annotation.Resource;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * 数据类型示例 服务接口类
 * @author zl
 * @since 2025-11-23 14:28:32
 */
@Api(tags = "数据类型示例服务接口类")
@RestController
@RequestMapping("test-data-types-management/v1.0/test-data-types")
public class TestDataTypesController {

    @Resource
    private TestDataTypesService testDataTypesService;

    @RequestMapping(value = "/query-with-page", method = RequestMethod.POST)
    @ApiOperation(value = "数据类型示例-分页查询", notes = "传入分页信息")
    public PageListResultDto<TestDataTypesDto> queryWithPage(@RequestBody TestDataTypesDto testDataTypesDto) {
        PageListResultDto<TestDataTypesDto> res;
        res = testDataTypesService.queryWithPage(testDataTypesDto, testDataTypesDto.getQueryParam());
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    
    @RequestMapping(value = "/query-with-no-page", method = RequestMethod.POST)
    @ApiOperation(value = "数据类型示例-不分页查询", notes = "传入查询条件信息")
    public ResponseDTO<List<TestDataTypesDto>> queryWithNoPage(@RequestBody TestDataTypesDto testDataTypesDto) {
        ResponseDTO<List<TestDataTypesDto>> res = new ResponseDTO<>();
        res.setData(testDataTypesService.queryWithNoPage(testDataTypesDto));
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }
    
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "数据类型示例-查询ById", notes = "传入id")
    public ResponseDTO<TestDataTypesDto> queryById(@PathVariable("id") String id) {
        ResponseDTO<TestDataTypesDto> res = new ResponseDTO<>();
        TestDataTypesDto result = testDataTypesService.queryById(id);
        res.setData(result);
        return res;
    }

    @RequestMapping(value = "/query-by-ids", method = RequestMethod.POST)
    @ApiOperation(value = "数据类型示例-查询ByIds", notes = "传入ids")
    public ResponseDTO<List<TestDataTypesDto>> queryByIds(@RequestBody List<String> ids) {
        ResponseDTO<List<TestDataTypesDto>> res = new ResponseDTO<>();
        res.setData(testDataTypesService.queryByIds(ids));
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ApiOperation(value = "数据类型示例-创建", notes = "创建")
    public ResultDto save(@RequestBody TestDataTypesDto testDataTypesDto) {
        ResultDto res = new ResultDto();
        testDataTypesService.save(testDataTypesDto);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/save-batch", method = RequestMethod.POST)
    @ApiOperation(value = "数据类型示例-创建", notes = "创建")
    public ResultDto saveBatch(@RequestBody List<TestDataTypesDto> testDataTypesDtos) {
        ResultDto res = new ResultDto();
        testDataTypesService.saveBatch(testDataTypesDtos);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    @ApiOperation(value = "数据类型示例-修改", notes = "修改")
    public ResultDto modify(@RequestBody TestDataTypesDto testDataTypesDto) {
        ResultDto res = new ResultDto();
        testDataTypesService.modify(testDataTypesDto);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/modify-batch", method = RequestMethod.POST)
    @ApiOperation(value = "数据类型示例-修改", notes = "修改")
    public ResultDto modifyBatch(@RequestBody List<TestDataTypesDto> testDataTypesDtos) {
        ResultDto res = new ResultDto();
        testDataTypesService.modifyBatch(testDataTypesDtos);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "数据类型示例-删除ById", notes = "传入id")
    public ResultDto delete(@PathVariable("id")  String id) {
        ResultDto res = new ResultDto();
        testDataTypesService.delete(id);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/delete-batch", method = RequestMethod.POST)
    @ApiOperation(value = "数据类型示例-批量删除", notes = "传入id")
    public ResultDto deleteBatch(@RequestBody List<String> ids) {
        ResultDto res = new ResultDto();
        testDataTypesService.deleteBatch(ids);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

}